using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace FoodWar.Episode1.Components.Particles
{
    public struct BillboardParticleElement
    {
        Vector3 position;
        Vector2 textureCoordinate;
        Color color;
        public Vector4 data;

        public Vector3 Position
        {
            get { return position; }
            set { position = value; }
        }
        public Vector2 TextureCoordinate
        {
            get { return textureCoordinate; }
            set { textureCoordinate = value; }
        }
        public Vector4 Data
        {
            get { return data; }
            set { data = value; }
        }
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }

        public Vector3 Speed
        {
            get { return new Vector3(data.X, data.Y, data.Z); }
            set { data.X = value.X; data.Y = value.Y; data.Z = value.Z; }
        }
        public float Time
        {
            get { return data.W; }
            set { data.W = value; }
        }

        public BillboardParticleElement(Vector3 Position, Vector2 TextureCoordinate, Vector3 Speed, Color Color)
        {
            position = Position;
            textureCoordinate = TextureCoordinate;
            data = new Vector4(Speed,0);
            color = Color;
        }
        static public VertexElement[] VertexElements = new VertexElement[]
        {
            new VertexElement(0,VertexElementFormat.Vector3,VertexElementUsage.Position,0),
            new VertexElement(4*3,VertexElementFormat.Vector2,VertexElementUsage.TextureCoordinate,0),                
            new VertexElement(4*5,VertexElementFormat.Color ,VertexElementUsage.Color,0),
            new VertexElement(4*6,VertexElementFormat.Vector4,VertexElementUsage.Position,1),
        };

        public void AddTime(float time)
        {
            this.data.W += time;
        }

        public static int SizeInBytes = (3 + 2 + 1 + 4) * 4;
    }
}
